﻿ 
<!DOCTYPE html>  
<html>  
<head>  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
    <meta name="keywords" content="公司">  
    <meta name="description" content="公司">  
    <title>Bd客户选择</title>  
    
    <%@ include file="/WEB-INF/inc/default.jsp"%>
    <jsp:include page="/WEB-INF/inc/dic.jsp"/>

</head>  
  <script>
      
         function doSelect(pcallback){
           var rows = $('#dg').datagrid('getSelections');
            if (!rows||rows.length==0){
            	 $.messager.alert('提示','请选择行','info');
            	 return;
            }
            if (!rows||rows.length>1){
            	 $.messager.alert('提示','不能选择多行','info');
            	 return;
            }
            
            if (rows){  
            	  var customer={};
                customer.id=rows[0].id;
                customer.name=rows[0].abbrName;
                
                
                if (callback) callback(customer);
                if(closeWin) closeWin();
            }  
         }
       
  </script>
<body>  
    
    
    <table id="dg"   style="width:1030px;height:350px"  
            url="/customer/customer/bdcustomerlist.do"  
            toolbar="#toolbar" pagination="true"  
            rownumbers="true" fitColumns="true" loadMsg="正在查询,请稍候..." singleSelect="false">  

    </table>  
    <div  style="text-align:center">  
          <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="doSelect();">确定</a>            
          <a href="javascript:void(0)" id="btn-close" class="easyui-linkbutton" onclick="closeWin()" iconCls="icon-cancel">关闭</a>  
    </div>
    
    <div id="toolbar">  
        公司名:<input id="input_name" class="easyui-box" style="width:80px">        
        <a href="#" class="easyui-linkbutton" onclick="quickQuery()" iconCls="icon-search">查询</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="find()">高级查询</a>
    </div>  
    
     <!-- query form窗体(开始) -->  
    <div id="dlg_query" style="display:none;">  
       <!--     
          <div itemId="tab_panel" class="easyui-tabs" style="width:580px;height:300px">
    	        <div title="基本查询"  style="padding:10px"> 
                  
                  <form itemId="fmquery" method="post" novalidate>  
            
              
	        		     <div class="fitem">  
                     <label style="width:100px">公司名:</label>                                            
                     <input name="name" class="easyui-box">                       
                   </div> 
	        		     <div class="fitem">  
                     <label style="width:100px">全名:</label>                                            
                     <input name="fullName" class="easyui-box">                       
                   </div> 
	        		     <div class="fitem">  
                     <label style="width:100px">abbrName:</label>                                            
                     <input name="abbrName" class="easyui-box">                       
                   </div> 
        	  	   	 <div class="fitem">  
                     <label style="width:100px">行业:</label>                                            
                     
                     
                     <input class="easyui-combobox" name="industry" style="width:200px;"  data-options="data:__getCategory('INDUSTRY'),valueField:'id', textField:'codeNameCn', multiple:false,panelHeight:'auto',mode:'remote' ">
                     
                   </div>      	
        	  	   	 <div class="fitem">  
                     <label style="width:100px">公司性质:</label>                                            
                     
                     
                     <input class="easyui-combobox" name="property" style="width:200px;"  data-options="data:__getCategory('COMPANY_NATURE'),valueField:'id', textField:'codeNameCn', multiple:false,panelHeight:'auto',mode:'remote' ">
                     
                   </div>      	
        	  	   	  <div class="fitem">  
                     <label style="width:100px">机构类型:</label>                                            
                     
                     
                     <input class="easyui-combobox" name="type" style="width:200px;"  data-options="data:__getCategory('ORGANIZATION_TYPE'),valueField:'id', textField:'codeNameCn', multiple:false,panelHeight:'auto',mode:'remote' ">
                     
                   </div>      	
	        		      	        		                                 
                 </form>
	                
             </div>  
             <div title="高级查询"  style="padding:10px"> 
                  <form itemId="fmquery" method="post" novalidate>  
            
              
	        		     <div class="fitem">  
                     <label style="width:100px">公司名:</label>                                            
                     <input name="name" class="easyui-box">                       
                   </div> 
	        		     <div class="fitem">  
                     <label style="width:100px">全名:</label>                                            
                     <input name="fullName" class="easyui-box">                       
                   </div> 
	        		     <div class="fitem">  
                     <label style="width:100px">abbrName:</label>                                            
                     <input name="abbrName" class="easyui-box">                       
                   </div> 
        	  	   	 <div class="fitem">  
                     <label style="width:100px">行业:</label>                                            
                     
                     
                     <input class="easyui-combobox" name="industry" style="width:200px;"  data-options="data:__getCategory('INDUSTRY'),valueField:'id', textField:'codeNameCn', multiple:false,panelHeight:'auto',mode:'remote' ">
                     
                   </div>      	
        	  	   	 <div class="fitem">  
                     <label style="width:100px">公司性质:</label>                                            
                     
                     
                     <input class="easyui-combobox" name="property" style="width:200px;"  data-options="data:__getCategory('COMPANY_NATURE'),valueField:'id', textField:'codeNameCn', multiple:false,panelHeight:'auto',mode:'remote' ">
                     
                   </div>      	
        	  	   	  <div class="fitem">  
                     <label style="width:100px">机构类型:</label>                                            
                     
                     
                     <input class="easyui-combobox" name="type" style="width:200px;"  data-options="data:__getCategory('ORGANIZATION_TYPE'),valueField:'id', textField:'codeNameCn', multiple:false,panelHeight:'auto',mode:'remote' ">
                     
                   </div>      	
	        		      	        		                                 
                 </form>
	                
            </div>    
            
        </div>
        <div  style="text-align:center">  
                    <a href="javascript:void(0)" itemId="btn-query" class="easyui-linkbutton" iconCls="icon-ok" ">确定</a>  
                    <a href="javascript:void(0)" itemId="btn-close" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>  
        </div>
          
        
        -->
        
    </div> 
    <!-- query form窗体(结束) -->   


    <script type="text/javascript">  
        var url;  
        var confWin;  
        
        function closeWin(){
        	  window.close();
        }	
        function quickQuery(){                                  
                var formdata='{name:'+('"'+$('#input_name').val()+'"')+'}';
                
                var jsondata=eval('('+formdata+')');
                
                if (!$('#fm_query').form('validate')) return; 
                $('#dg').datagrid({
	                  queryParams: jsondata
                });
               $('#dlg_query').dialog('close');
              
        }	
       function find(){
     	   if (confWin)
     	        confWin.window('open');
			    else confWin = $.window({
			    	title:"查询",
			    	tplRef:"dlg_query",//这个属性指定模板id
			    	height:400,
			    	width:600,
			    	onComplete:function(){
			    		//窗口里面的初始化,最好是在这个事件里面进行
			    		var curWin=this;
			    		
			    		
			    		this.find('a[itemId="btn-query"]').click(function(){
			    		
			    			  if (!curWin.curForm) curWin.curForm=curWin.find('form[itemId="fmquery"]');
			    			  //console.log(curWin.curForm);
			    			  curWin.window('close');
			    			  var formdata=curWin.curForm.formToArray();   		 
		              curWin.openerWin.query(formdata);
			    		});
			    		this.find('a[itemId="btn-close"]').click(function(){
			    			  curWin.window('close');
			    	  });
			    	  
			    	  
			    	  this.find('div[itemId="tab_panel"]').tabs({
        	          onSelect: function(title,index){        	          
        	          	var tab=curWin.find('div[itemId="tab_panel"]').tabs('getTab', index);        	          
        	          	curWin.curForm=tab.find('form[itemId="fmquery"]');  
        	          	//console.log(curWin.curForm);
        	          	        	          	
        	          }
             }); 
			    	  
			    		
			    	}
			    });
			    confWin.openerWin=window;
			    
		 }
		 
		   function query(formdata){  
                
                $('#dg').datagrid({
	                  queryParams: array2json(formdata)
                });
              
        }
        
        //生成grid的字段,需要字典的自动转换
        $('#dg').datagrid({
        	   columns:[[
        	   	    {field:'id',title:'公司编号', width:100,hidden:true}
        	   	   ,{field:'abbrName',title:'公司简称', width:100}
        	   	   ,{field:'name',title:'公司中文名', width:100,hidden:true}
        	   	   ,{field:'fullName',title:'公司英文名', width:100,hidden:true}        	   	   
        	   	   ,{field:'industry',title:'行业', width:100,hidden:true,
        	   		      formatter: function(value,row,index){
        	   		      	return __getCategroyCodeValue('INDUSTRY', value);
        	   		      }
        	   	     }
        	   	   ,{field:'property',title:'公司性质', width:100,
        	   		      formatter: function(value,row,index){
        	   		      	return __getCategroyCodeValue('COMPANY_NATURE', value);
        	   		      }
        	   	     }
        	   	   ,{field:'type',title:'机构类型', width:100,
        	   		      formatter: function(value,row,index){
        	   		      	return __getCategroyCodeValue('ORGANIZATION_TYPE', value);
        	   		      }
        	   	     }
        	   	   ,{field:'tel',title:'电话总机', width:100,hidden:true}
        	   	   ,{field:'website',title:'网站', width:100,hidden:true}
        	   	   ,{field:'location',title:'城市', width:100,
        	   		      formatter: function(value,row,index){
        	   		      	return __getCategroyCodeValue('LOCATION', value);
        	   		      }
        	   	     }
        	   	   ,{field:'address',title:'地址', width:100}
        	   	   
        	   	
        	   	
        	   ]]
        	   ,onDblClickRow: function(rowIndex, rowData){
        	    	$('#dlg').dialog('open').dialog('setTitle','修改公司');                  
                $('#fm').form('load','/customer/company/get.do?id='+rowData.id);  
                url = '/customer/company/update.do';        	    	
        	    }
        }); 
        //完成-生成grid的字段
        
        
        /*
         $('#dg').datagrid({
        	    onDblClickRow: function(rowIndex, rowData){
        	    	$('#dlg').dialog('open').dialog('setTitle','修改公司');                  
                $('#fm').form('load','/customer/company/get.do?id='+rowData.id);  
                url = '/customer/company/update.do';        	    	
        	    }
        });*/
    </script>  
     
     

     
     
     
</body>  
</html>